home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / TUTOROOT.PAK / STEP02.CPP < prev    next >
C/C++ Source or Header  |  1997-05-06  |  2KB  |  71 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1991, 1994 by Borland International
  3. //   Tutorial application -- step02.cpp
  4. //----------------------------------------------------------------------------
  5. #include <owl/pch.h>
  6. #include <owl/applicat.h>
  7. #include <owl/framewin.h>
  8.  
  9. class TDrawWindow : public TWindow {
  10.   public:
  11.     TDrawWindow(TWindow* parent = 0);
  12.  
  13.   protected:
  14.     // Override member function of TWindow
  15.     bool CanClose();
  16.  
  17.     // Message response functions
  18.     void EvLButtonDown(uint, TPoint&);
  19.     void EvRButtonDown(uint, TPoint&);
  20.  
  21.   DECLARE_RESPONSE_TABLE(TDrawWindow);
  22. };
  23.  
  24. DEFINE_RESPONSE_TABLE1(TDrawWindow, TWindow)
  25.   EV_WM_LBUTTONDOWN,
  26.   EV_WM_RBUTTONDOWN,
  27. END_RESPONSE_TABLE;
  28.  
  29. TDrawWindow::TDrawWindow(TWindow* parent)
  30. {
  31.   Init(parent, 0, 0);
  32. }
  33.  
  34. bool
  35. TDrawWindow::CanClose()
  36. {
  37.   return MessageBox("Do you want to save?", "Drawing has changed",
  38.                     MB_YESNO | MB_ICONQUESTION) == IDNO;
  39. }
  40.  
  41. void
  42. TDrawWindow::EvLButtonDown(uint, TPoint&)
  43. {
  44.   MessageBox("You have pressed the left mouse button",
  45.     "Message Dispatched", MB_OK);
  46. }
  47.  
  48. void
  49. TDrawWindow::EvRButtonDown(uint, TPoint&)
  50. {
  51.   MessageBox("You have pressed the right mouse button",
  52.     "Message Dispatched", MB_OK);
  53. }
  54.  
  55. class TDrawApp : public TApplication {
  56.   public:
  57.     TDrawApp() : TApplication() {}
  58.  
  59.     void InitMainWindow()
  60.     {
  61.       SetMainWindow(new TFrameWindow(0, "Sample ObjectWindows Program",
  62.         new TDrawWindow));
  63.     }
  64. };
  65.  
  66. int
  67. OwlMain(int /*argc*/, char* /*argv*/ [])
  68. {
  69.   return TDrawApp().Run();
  70. }
  71.